var currModelId='13';//当前模块id


var Page={
	init: function() {
	},
	search: function(page) {
		var param={
			pageNo: page ? page : 1,
			pageSize: 10,
			name: $('#p_org_name').val(),
			parentname: $('#p_org_parnet_name').val(),
			remarks: $('#p_org_desc').val()
		};
		apps.request({
			type: 'GET',
			url: urls.ctx + '/sys/office/query',
			data: param,
			success: function(res){
				if(res && res.code == 0) {
					let h = '';
					for(let i = 0, len = res.data.length; i < len; i++) {
						var item = res.data[i];
						item.parent_name = item.parent_name ? item.parent_name : '';
						h += '<tr data-id="' + item.id + '">';
						h += '<td>' + item.name + '</td>';
						h += '<td>' + item.code + '</td>';
						h += '<td>' + item.parent_name + '</td>';
						h += '<td>' + item.office_type + '</td>';
						h += '<td>' + item.office_grade + '</td>';
						h += '<td>' + '<a href="javascript:void(0);" class="edit">修改</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="edit">删除</a>' + '</td>';
						
						h += '</tr>';
					}
					//列表数据添加
					$('#tbody-data').html(h);
					//页码显示
					if(res.totalpage > 0) {
						$(".pagination2").jqPaginator({
							totalPages: res.totalpage,
							totalCounts: res.count,
							visiblePages: res.pageSize?res.pageSize:10,
							currentPage: res.page,
							prev: '<a class="prev" href="javascript:void(0);">&lt;<\/a>',
							next: '<a class="next" href="javascript:void(0);">&gt;<\/a>',
							page: '<a href="javascript:void(0);">{{page}}<\/a>',
							onPageChange: function(n) {
								if(res.page != n) {
									Page.search(n);
								}
							}
						})
					} else {
						$(".pagination2").html('');
					}
					
					
					// $('#office-page-id').jqPaginator({
						// totalPages: res.totalpage,
						// visiblePages: res.pageSize?res.pageSize:10,
						// currentPage: res.page,
						// first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
						// prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>',
						// next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>',
						// last: '<li class="last"><a href="javascript:void(0);">末页<\/a><\/li>',
						// page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
						// onPageChange: function(n) {
							// if(res.page != n) {
								// Page.search(n);
							// }
						// }
					// });
				}
			}
		});
	},
	
};

$(document).ready(function(){
	
	
	Page.search();
	//事件绑定
	$('#p_search').click(function() {
		Page.search();
	});
	
	
	
	
	
	
	
	
	
	
	
});

